
<%

String strPrevMenuSel="";
if(request.getAttribute("PrevSelMenu")!=null){
	strPrevMenuSel=(String)request.getAttribute("PrevSelMenu");
}
   String onDate = null;
	if(request.getAttribute("CurrentDate")!=null){
		onDate=(String)request.getAttribute("CurrentDate");
	}
	
   int reportIndx=0;
  if( request.getAttribute("reportIndx")!=null){
	  reportIndx=Integer.parseInt(request.getAttribute("reportIndx").toString());
  }
  
	
	
	String reportname = "";
	switch(reportIndx) {
	// CashManagement Report
	case 1:
			reportname =  "Cash Management ";
			break;
		// MiscJobs Report
	case 2:
			reportname = "Misc Jobs";
		break;
		// PrintJobsByOrderDate Report
	case 3:
			reportname =  "Print Jobs";
			break;
		//OutStandings Report
	case 4:
			reportname =  "OutStandings";
		break;
		// Refund Report
	case 5:
			reportname =  "Refunds";
		break;
	case 6:
			reportname =  "Bad Debts";
		break;
	case 8:
		reportname =  "My Collection";
	break;
	case 9:
		reportname =  "Cancellation";
	break;

	}
	
%>

<%@page import="java.text.SimpleDateFormat"%>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery/jquery.js"></script>
<script src="<%=request.getContextPath()%>/js/jquery/ui/ui.core.js" type="text/javascript" ></script>
<script src="<%=request.getContextPath()%>/js/jquery/ui/ui.datepicker.js" type="text/javascript" ></script>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/themes/base/ui.all.css">
<script src="<%=request.getContextPath()%>/js/dateutils.js" type="text/javascript" ></script>
<script language="javascript">
		
			function doDateCheck() {
				var fromTemp = document.rptForm.fromDate.value;

				var fdd = fromTemp.slice(0,2);
				var fmm = fromTemp.slice(3,5);
				var fyy = fromTemp.slice(6,10);
				
				var toTemp = document.rptForm.toDate.value;
				
				var tdd = toTemp.slice(0,2);
				var tmm = toTemp.slice(3,5);
				var tyy = toTemp.slice(6,10);
				
				var fromDate = new Date(fyy,fmm,fdd);
				var toDate = new Date(tyy,tmm,tdd);
				
				if (fromDate > toDate) {
					alert("To date should be greater than or equal to the From date.");
					return false;
				}

				return true;
			}

			function csvReport(){
				document.getElementById('isCSVReports').value = 1;
				openReport();
			}

			function htmlReport(){
				document.getElementById('isCSVReports').value = 0;
				openReport();
			}
			
			function openReport(){
				var reportIndx=<%=reportIndx%>;
				var reportType = -1;
				var csvReport = document.getElementById('isCSVReports').value;
				if(reportIndx == 8 || reportIndx == 9){
					 reportType = -1;
				}else{
					 reportType=document.getElementById('reportType').value;
				}
				var fromDate = document.getElementById('fromDate').value;
				var toDate = document.getElementById('toDate').value;
				var pageId = document.getElementById('pageId').value;
				var eventId = document.getElementById('eventId').value;

				doDateCheck();
				
				childwin = window.open ('ViewReport.do?pageId='+pageId+'&eventId='+eventId+'&fromDate='+fromDate+'&toDate='+toDate+'&reportIndx='+reportIndx+'&reportType='+reportType+'&csvReport='+csvReport, 'newwindow', config='height=' + screen.height + ',width=' +  screen.width + ', toolbar=1,left=0,top=0, menubar=1, scrollbars=1, resizable=1,location=1, directories=1, status=1');				
			}
		
			
 			
		</script>
<script type="text/javascript">
	$(function() {
		dpCurrServDate = yyyyMmDdToDate('<%= onDate%>');	
		$("#fromDate").datepicker({showOn: 'button',dateFormat: 'yy-mm-dd' , maxDate: '0D' , buttonImage: 'images/calender.png', buttonImageOnly: true});
		$("#toDate").datepicker({showOn: 'button',dateFormat: 'yy-mm-dd' , maxDate: '0D' , buttonImage: 'images/calender.png', buttonImageOnly: true});
	});
</script>
<form name="rptForm" method="post" action="dateSelect.do"
	onsubmit="return doDateCheck();">
	<input type="hidden"
	name="pageId" id="pageId" value='18' />
	 <input type="hidden"
	name="eventId" id="eventId" value='1' />
	<input type="hidden" name="isCSVReports" id="isCSVReports" value='0' />
 <input type="hidden" name="PrevSelMenu" id="PrevSelMenu" value="<%=strPrevMenuSel%>"/>
<div style="width: 500px;">
<div id="left_side"><h3><span>&nbsp;&nbsp;<%=reportname%> &nbsp;&nbsp;Report</span></h3></div>
<table  width="100%" cellpadding="2"  cellspacing="2" class="bordered_table">
	<tr>
		<td class="td_font" width="30%">From Date :</td>
		<td class="td_font" width="70%"><input name="fromDate" id="fromDate" type="text"
			readonly="readonly" size="15" value="<%=onDate %>"/> 
		</td>
	</tr>
	<tr>
		<td class="td_font" width="30%">To Date :</td>
		<td class="td_font" width="70%"><input name="toDate" id="toDate" type="text"
			readonly="readonly" size="15" value="<%=onDate %>"/>
			
		</td>
	</tr>
	<tr>
		<td class="td_font" width="30%">
		<% if(reportIndx != 8 && reportIndx != 9){ %>
		<div id="selectTypeLabel">Type :</div>
		</td>
		<td class="td_font" width="70%" align="left">
		<select id="reportType" name="reportType" style="width: 150px;">
			<option value='1'>Order Wise</option>
			<% if(reportIndx == 1 ){ %>	
			
			<option value='2'>Payment Wise</option>
			<%} %>
		</select>
		</td>
		<%} %>
	</tr>
	<tr align="center">
		<td class="td_font" align="center" colspan="2">&nbsp;</td>
	</tr>
	<tr align="center">
		<td class="td_font" align="right" ><input type="button" class="form_bttn" name="htmlSubmit"
			value="Html Reports" onclick="htmlReport();" /></td>
		<td class="td_font" align="center" ><input type="button" class="form_bttn" name="CSVReport"
			value="CSV Report" onclick="csvReport();" /></td>

	</tr>
</table>
</div>
</form>
